package pomodorotasks

import ca.odell.glazedlists.BasicEventList
import ca.odell.glazedlists.EventList
import ca.odell.glazedlists.event.ListEventListener
import ca.odell.glazedlists.event.ListEvent
import ca.odell.glazedlists.swing.EventComboBoxModel

addAction = action(name: 'Add', closure: controller.addAction)
changeListAction = action(name: 'Change list', closure: controller.changeListAction)


class TitleEventComboBoxModel extends EventComboBoxModel {
    
    TitleEventComboBoxModel(EventList source) {
        super(source)
    }
    
    Object getElementAt(int index) {
        return super.getElementAt(index).title
    }
    
}

app = application(title: 'PomodoroTasks',
    preferredSize: [640, 480],
    pack: true,
    //location: [50,50],
    locationByPlatform:true,
    iconImage: imageIcon('/griffon-icon-48x48.png').image,
    iconImages: [imageIcon('/griffon-icon-48x48.png').image,
        imageIcon('/griffon-icon-32x32.png').image,
        imageIcon('/griffon-icon-16x16.png').image]) {
    borderLayout()
    hbox(constraints:NORTH) {
        button(action: addAction)
        listsComboBox = comboBox(action: changeListAction, 
            model: new TitleEventComboBoxModel(model.lists)
        )
    }
    listsPane = tabbedPane(constraints:CENTER)
}
